package net.hombrecero.bigbeat.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.hibernate.annotations.AccessType;

@Entity
@AccessType( "field" )
public class WorkUnit extends Base {
	public static final int STATUS_NOT_PROCESSED   = 1;
	public static final int STATUS_PROCESSING      = 2;
	public static final int STATUS_PROCESSED_OK    = 4;
	public static final int STATUS_PROCESSED_ERROR = 8;
	//
	public static final int VISIBILITY_HIDDEN      = 1;
	public static final int VISIBILITY_VISIBLE     = 2;



    @ManyToOne( cascade = { CascadeType.PERSIST, CascadeType.MERGE } )
    @JoinColumn( name="uuidProject", nullable=false )
    private Project project;
	@OneToMany( targetEntity = Result.class, mappedBy = "workUnit" , cascade = { CascadeType.ALL } )
	private Set results = new HashSet();
    @ManyToOne( cascade = { CascadeType.PERSIST, CascadeType.MERGE } )
    @JoinColumn( name="uuidUser", nullable=false )
    private User user;
    @ManyToOne( cascade = { CascadeType.PERSIST, CascadeType.MERGE } )
    @JoinColumn( name="uuidSubSet1", nullable=false )
    private SubSet subSet1;
    @ManyToOne( cascade = { CascadeType.PERSIST, CascadeType.MERGE } )
    @JoinColumn( name="uuidSubSet2", nullable=false )
    private SubSet subSet2;
	@Column( nullable = false )
	private int priority = 0;
	@Column( nullable = false )
	private int visibility = VISIBILITY_HIDDEN;
	@Column( nullable = false )
	private int status = STATUS_NOT_PROCESSED;
    @Column( length=32, nullable = false )
	private String statusDescription;



	public Project getProject() {
		return this.project;
	}
	public void setProject( Project project ) {
		this.project = project;
	}
	public Set getResults() {
		return this.results;
	}
	public void setResults( Set results ) {
		this.results = results;
	}
	public User getUser() {
		return this.user;
	}
	public void setUser( User user ) {
		this.user = user;
	}
	public String getStatusDescription() {
		return this.statusDescription;
	}
	public void setStatusDescription( String name ) {
		this.statusDescription = name;
	}
	public int getPriority() {
		return this.priority;
	}
	public void setPriority( int priority ) {
		this.priority = priority;
	}
	public int getStatus() {
		return this.status;
	}
	public void setStatus( int status ) {
		this.status = status;
	}
	public int getVisibility() {
		return this.visibility;
	}
	public void setVisibility( int visibility ) {
		this.visibility = visibility;
	}
	public SubSet getSubSet1() {
		return this.subSet1;
	}
	public void setSubSet1( SubSet subSet1 ) {
		this.subSet1 = subSet1;
	}
	public SubSet getSubSet2() {
		return this.subSet2;
	}
	public void setSubSet2( SubSet subSet2 ) {
		this.subSet2 = subSet2;
	}
}
